package yja.gzw.app.fragmentview

import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import yja.gzw.app.R
import yja.gzw.app.adapter.FensiAdapter
import yja.gzw.app.adapter.WodeguanzhuAdapter
import yja.gzw.app.base.BaseFragment
import yja.gzw.app.databinding.FragmentWodeGuanzhuBinding
import yja.gzw.app.model.UserData
import yja.gzw.app.viewmodel.Mainviewmodel

class WodeGuanzhuFragment :BaseFragment<Mainviewmodel, FragmentWodeGuanzhuBinding>(R.layout.fragment_wode_guanzhu){

    private lateinit var fabiada: WodeguanzhuAdapter
    override fun initView() {
        viewmodel.onwodeguanzhuwang(UserData.token, mapOf("page" to "1"))
    }
    override fun onResume() {
        super.onResume()
        viewmodel.onwodeguanzhuwang(UserData.token, mapOf("page" to "1"))
    }
    override fun dataObservese() {
        viewmodel.onwodeguanzhu.observe(this, Observer {
            if(it.code==1){
                Toast.makeText(context,it.msg, Toast.LENGTH_SHORT).show()
                binding.review.layoutManager=
                    LinearLayoutManager(context)
                fabiada= WodeguanzhuAdapter(requireContext(),it.data.data)
                binding.review.adapter= fabiada

            }else{
                Toast.makeText(context,it.msg, Toast.LENGTH_SHORT).show()
            }

        })

    }
}